import { fetchMenuTree } from '@/services/admin/menu'
import { MENU } from '@/services/admin/typings'
import { flow, makeAutoObservable } from 'mobx'

class TenantModel {
  menuTree?: MENU.MenuTreeVO[]
  selectMenuKey: number[] = [83, 84, 90]

  constructor() {
    console.log('初始化tenantModel')
    makeAutoObservable(this, {}, { autoBind: true })
  }

  setSelectMenuKey(keys: number[]) {
    console.log(keys)
    console.log(this.selectMenuKey)
    this.selectMenuKey = keys
  }

  fetchMenuTree = flow(
    function* () {
      // @ts-ignore
      this.menuTree = yield fetchMenuTree()
    }.bind(this),
  )
}

export default TenantModel

export const tenantModel = new TenantModel()
